﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Helpers
{
    public class ParsingHelpers
    {
        public static String AppendWithSingleQuote(String value)
        {
            return "'" + value + "'";
        }


        public static String ReplaceString(String originalValue, String valueToReplace, String replacingValue)
        {
            originalValue = originalValue.Replace(valueToReplace, replacingValue);
            return originalValue;

        }

        public static string CleanString(string inputString)
        {
            return (string.IsNullOrEmpty(inputString) ? string.Empty : inputString).Replace("&", "&amp;").Replace("null", "");
        }

        public static String CleanNullOrEmptyValue(object value)
        {
            return ((value != null && !String.IsNullOrEmpty(value.ToString())) ? value.ToString() : String.Empty);
        }

        public static String CheckContainsComma(String value, String inputName, String prospectId = default(String))
        {

            if (value.Contains(","))
            {
                if (prospectId != default(String))
                {
                    throw new Exception(inputName + " contains comma. " + inputName + " is: " + value + "  ProspectId: " + prospectId);
                }
                else
                {
                    throw new Exception(inputName + " contains comma. " + inputName + " is: " + value);
                }
            }

            return value;
        }

      

  
    
    }
}
